 /**
 * 逻辑、功能相关描述: <br>
 *
 * @author 付湘辉  <br>
 * 编写日期：2008-10-29  <br>
 */
package com.ce.pms.common.service.impl;

import com.ce.pms.base.service.impl.PmsBaseServiceImpl;
import com.ce.pms.common.dao.ISecUserDao;
import com.ce.pms.common.model.HmDeptDomain;
import com.ce.pms.common.model.HmEmployeeDomain;
import com.ce.pms.common.model.SecUser;
import com.ce.pms.common.service.ISecUserService;
import com.ce.pms.common.vo.OrganizationalStructureVO;
import com.ce.util.BeanUtil;
import com.ce.util.BlankUtil;

/**
 * 	名称: com.ce.pms.common.service.impl.SecUserServiceImpl <br>
 *
 *
 * @author  付湘辉  <br>
 * Created on： 2008-10-29 <br>
 * @author <br>
 * update on： <br>
 * why: <br>
 */
public class SecUserServiceImpl extends PmsBaseServiceImpl implements
		ISecUserService {
	private ISecUserDao secUserDao;

	public void setSecUserDao(ISecUserDao secUserDao) {
		this.secUserDao = secUserDao;
	}

	/**
	 * 功能描述: 根据id查询用户信息 <br>
	 * @param userId 用户id
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-10-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public OrganizationalStructureVO getUserById(Long userId) {
		super.checkParameterIsNull(userId, "common:parameters_null_exception, ");

		SecUser user = this.secUserDao.findById(userId);
		if (BlankUtil.isBlank(user)) {
			return null;
		}
		OrganizationalStructureVO userVo = new OrganizationalStructureVO();
		BeanUtil.convertVoAsDo(user, userVo);
		HmEmployeeDomain employee = user.getEmployeeDO();
		if (!BlankUtil.isBlank(employee)) {
			userVo.setEmployeeName(employee.getEmployeeName());
			userVo.setEmplyeeId(employee.getEmployeeId());
			HmDeptDomain dept = employee.getDeptDO();
			if (!BlankUtil.isBlank(dept)) {
				userVo.setDept(dept.getDeptName());
			}
		}

		return userVo;
	}

	/**
	 * 功能描述: 根据id查询用户名称 <br>
	 * @param userId 用户id
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-10-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public String queryUserNameById(Long userId) {
		super.checkParameterIsNull(userId, "common:parameters_null_exception, ");
		String userName = this.secUserDao.queryUserNameById(userId);
		return BlankUtil.isBlank(userName)?null:userName;
	}

}
